<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  //文件上传multipart/form-data
  <form action="" method="post" enctype="multipart/form-data">
    头像: <input type="file" name="file" id="">
    <input type="submit" value="提交">
  </form>

  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <button class="btn_get">get请求-列表</button>
  <button class="btn_post">post请求-查询员工信息</button>
  <button class="btn_delete">delete请求-删除</button>
  <script>
    axios.defaults.baseURL = "http://localhost:8090/"
    // 登录成功后为请求头添加令牌|权限
    // 添加请求拦截器
    axios.interceptors.request.use(function (config) {
      console.log(config.url)
      //任何请求都会经过这一步   在发送请求之前做些什么
      config.headers.token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1OTE1OTU3LCJleHAiOjE3MTU5NjYwMjJ9.ZjeckRuSMHpsojotO9AgCjWhDC40TocM7oXCJq9EsjqttzHseBbr8hbByDsTmKtpxLqkM76XD5oGvkAN6TeKrg';
      //这里一定要return   否则配置不成功
      return config;
    }, function (error) {
      // 对请求错误做些什么
      //return Promise.reject(error);
      console.log(err)
    });
    document.querySelector('.btn_post').addEventListener("click", () => {

      axios.post("/employee/lists", {
        "status": "在职",
      }
        // ,
        // {
        //   headers: {
        //     "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1OTE1OTU3LCJleHAiOjE3MTU5NjYwMjJ9.ZjeckRuSMHpsojotO9AgCjWhDC40TocM7oXCJq9EsjqttzHseBbr8hbByDsTmKtpxLqkM76XD5oGvkAN6TeKrg"
        //   }
        // }
      ).then((result) => {
        console.log(result.data);
        if (result.data.code == 200) {
          console.log(result.data.data);
        }
      }).catch((err) => {

      });
    })
    // document.querySelector('.btn_post').addEventListener("click", () => {

    //   axios.post("/employee/lists", {
    //     "status": "在职",
    //   }, {
    //     headers: {
    //       "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNzE1OTE1OTU3LCJleHAiOjE3MTU5NjYwMjJ9.ZjeckRuSMHpsojotO9AgCjWhDC40TocM7oXCJq9EsjqttzHseBbr8hbByDsTmKtpxLqkM76XD5oGvkAN6TeKrg"
    //     }
    //   }
    //   ).then((result) => {
    //     console.log(result.data.data);
    //   }).catch((err) => {

    //   });
    // })
  </script>
</body>

</html>